/*
 * @Description: jishupu-admin-template
 * @Author: 技术铺<jishupu@qq.com>
 * @Date: 2022-03-03
 */
const { success } = require('./utils')

// 树形列表案例模块
module.exports = [
  // 列表
  {
    url: '/v1/example/example-tree-table$',
    type: 'get',
    response: config => {
      const result = {
        'items': [
          {
            'id': 1,
            'parent_id': 0,
            'name': '1级1',
            'sort': 1,
            'status': 1,
            'created_at': '2022-02-28 15:06:18',
            'updated_at': '2022-02-28 15:11:58',
            'children': [
              {
                'id': 3,
                'parent_id': 1,
                'name': '2级1',
                'sort': 1,
                'status': 1,
                'created_at': '2022-02-28 15:07:06',
                'updated_at': '2022-02-28 16:01:56'
              },
              {
                'id': 4,
                'parent_id': 1,
                'name': '2级2',
                'sort': 2,
                'status': 1,
                'created_at': '2022-02-28 15:07:17',
                'updated_at': '2022-02-28 15:11:58',
                'children': [
                  {
                    'id': 5,
                    'parent_id': 4,
                    'name': '3级1',
                    'sort': 1,
                    'status': 1,
                    'created_at': '2022-02-28 15:07:47',
                    'updated_at': '2022-02-28 15:08:09'
                  },
                  {
                    'id': 6,
                    'parent_id': 4,
                    'name': '3级2',
                    'sort': 2,
                    'status': 1,
                    'created_at': '2022-02-28 15:08:00',
                    'updated_at': '2022-02-28 15:11:58',
                    'children': [
                      {
                        'id': 7,
                        'parent_id': 6,
                        'name': '4级',
                        'sort': 1,
                        'status': 1,
                        'created_at': '2022-02-28 15:08:28',
                        'updated_at': '2022-02-28 15:11:58'
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            'id': 2,
            'parent_id': 0,
            'name': '1级2',
            'sort': 2,
            'status': 1,
            'created_at': '2022-02-28 15:06:39',
            'updated_at': '2022-02-28 15:07:34'
          }
        ],
        'total': 7
      }
      return success(result)
    }
  },
  // 上级
  {
    url: '/v1/example/example-tree-table/\\d+/parent-tree-config$',
    type: 'get',
    response: config => {
      const result = {
        'items': [
          {
            'id': 1,
            'parent_id': 0,
            'name': '1级1',
            'disabled': false,
            'children': [
              {
                'id': 3,
                'parent_id': 1,
                'name': '2级1',
                'disabled': false
              },
              {
                'id': 4,
                'parent_id': 1,
                'name': '2级2',
                'disabled': false,
                'children': [
                  {
                    'id': 5,
                    'parent_id': 4,
                    'name': '3级1',
                    'disabled': false
                  },
                  {
                    'id': 6,
                    'parent_id': 4,
                    'name': '3级2',
                    'disabled': false,
                    'children': [
                      {
                        'id': 7,
                        'parent_id': 6,
                        'name': '4级',
                        'disabled': false
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            'id': 2,
            'parent_id': 0,
            'name': '1级2',
            'disabled': false
          }
        ],
        'parent': {
          'id': 0,
          'name': ''
        },
        'parent_ids': []
      }
      return success(result)
    }
  },
  // 普通列表-分类树数据
  {
    url: '/v1/example/example-tree-table/tree-config$',
    type: 'get',
    response: config => {
      const result = {
        'items': [
          {
            'id': 1,
            'parent_id': 0,
            'name': '1级1',
            'children': [
              {
                'id': 3,
                'parent_id': 1,
                'name': '2级1'
              },
              {
                'id': 4,
                'parent_id': 1,
                'name': '2级2',
                'children': [
                  {
                    'id': 5,
                    'parent_id': 4,
                    'name': '3级1'
                  },
                  {
                    'id': 6,
                    'parent_id': 4,
                    'name': '3级2',
                    'children': [
                      {
                        'id': 7,
                        'parent_id': 6,
                        'name': '4级'
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            'id': 2,
            'parent_id': 0,
            'name': '1级2'
          }
        ]
      }
      return success(result)
    }
  },
  // 详情
  {
    url: '/v1/example/example-tree-table/\\d+$',
    type: 'get',
    response: config => {
      const result = {
        'id': 1,
        'parent_id': 0,
        'name': '1级1',
        'status': 1
      }
      return success(result)
    }
  },
  // 添加
  {
    url: '/v1/example/example-tree-table$',
    type: 'post',
    response: config => {
      return success({}, '添加成功')
    }
  },
  // 修改
  {
    url: '/v1/example/example-tree-table/\\d+$',
    type: 'put',
    response: config => {
      return success({}, '修改成功')
    }
  },
  // 模拟修改状态
  {
    url: '/v1/example/example-tree-table/\\d+/status',
    type: 'patch',
    response: config => {
      return success({}, '修改成功')
    }
  },
  // 模拟排序
  {
    url: '/v1/example/example-tree-table/sort',
    type: 'put',
    response: config => {
      return success({}, '排序成功')
    }
  },
  // 模拟删除
  {
    url: '/v1/example/example-tree-table/\.*',
    type: 'delete',
    response: config => {
      return success({}, '删除成功')
    }
  }
]
